<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    class Parent {
      constructor(name, age) {
        this.name = name
        this.age = age
      }
      sayHi() {
        console.log('大家好，我是父级', this.name)
      }
    }
    class Child extends Parent {
      // 如果子类不写constructor的话  js在执行的时候会自动的帮我们创建一个constructor，会自动传给父类
      constructor(name, age) {
        super(name, age)
        this.name = '牛逼'
      }
      stop() {
        console.log(this)
      }
    }
    let c1 = new Child('阿黄', 8)
    let p1 = new Parent('无名', 18)
    c1.stop()
    c1.sayHi()
    c1.age = 10
    console.log(p1)
    console.log(c1)

    // const bar = new Bar()
    // function Bar() {
    //   this.bar = 42;
    // }

    
    // class 声明内部会启用严格模式
    // const foo = new Foo() // Cannot access 'Foo' before initialization
    // class Foo {}
    
  </script>
</body>
</html>